'use strict';

const path = require('path');

module.exports = appInfo => {
    const config = exports = {};

    // seenreq
    // config.seenreq = {
    //     repo: 'redis',// use redis instead of memory
    //     host: '127.0.0.1',
    //     port: 6379,
    //     clearOnQuit: false,
    // };

    // config.proxy = 'http://localhost:8123'

    config.store = {
        path: 'output'
    }

    config.es = {
        template: {
            settings: {
                "number_of_replicas": 0
            },
            "mappings": {
                "properties": {
                  "_spider_time": {
                    "type": "date"
                  },
                  "date": {
                    "type": "date"
                  },              
                  "timestamp": {
                    "type": "date"
                  }
                },
                "dynamic_templates": [
                    {
                        "links_as_nested": {
                           "match": "links",
                           "mapping": {
                                "type": "nested"
                           }
                        },
                    },{
                        "videos_as_nested": {
                            "match": "videos",
                            "mapping": {
                                 "type": "nested"
                            }
                        },                        
                    },{
                        "list_as_nested": {
                            "match": "*list",
                            "mapping": {
                                 "type": "nested"
                            }
                        },    
                    },{
                        "all_as_strings": {
                            "match": "*",
                            "unmatch": "_spider_*",
                            "mapping": {
                                "type": "text",
				                "ignore_malformed": true,
                                "fields": {
                                    "keyword": {
                                        "type": "keyword",
                                        "ignore_above": 256
                                    }
                                }
                            }
                        }
                    }
                ]
            }
        }
    }


    return {
        ...config,
    };
};
